Skip to content

[geo-layers] Fix TerrainLayer globe Mercator tile warping#10293

Open
charlieforward9 wants to merge 2 commits into
visgl:cr/feat/terrain-layer-globe-gridfrom
NEW-HEAT:codex/terrain-globe-mercator-remap
Open

[geo-layers] Fix TerrainLayer globe Mercator tile warping#10293
charlieforward9 wants to merge 2 commits into
visgl:cr/feat/terrain-layer-globe-gridfrom
NEW-HEAT:codex/terrain-globe-mercator-remap

Conversation

@charlieforward9
Copy link
Copy Markdown
Collaborator

@charlieforward9 charlieforward9 commented May 12, 2026

Summary

Fixes GlobeView terrain and bitmap tile warping for WebMercator tiles by remapping tile rows through inverse WebMercator instead of treating rows as linearly spaced latitude.

Why

WebMercator tiles do not encode latitude linearly from top to bottom. On GlobeView, using linear latitude for mesh rows compresses terrain and imagery near the poles and becomes very visible at far zooms.

Change

  • Updates TerrainLayer globe mesh generation to remap row latitude from WebMercator tile coordinates.
  • Applies the same Mercator-aware remapping path to bitmap tiles in GlobeView.
  • Adds regression coverage for terrain globe warping and tile-layer globe row mapping.

Validation

  • Added tests in test/modules/geo-layers/terrain-layer.spec.ts and test/modules/geo-layers/tile-layer/tile-layer.spec.ts.
  • CI is green on the stacked branch.

Visual

Before, terrain is visibly warped:
https://github.com/user-attachments/assets/2154f023-8df4-422c-a2f3-fd05006d0be4

Merge Notes

Stacked on #10250 / base branch cr/feat/terrain-layer-globe-grid. Merge after its base terrain-grid work is accepted.

@charlieforward9 charlieforward9 force-pushed the codex/terrain-globe-mercator-remap branch from 7a58fd4 to 6bf36a5 Compare May 12, 2026 21:07
@coveralls
Copy link
Copy Markdown

coveralls commented May 12, 2026

Coverage Status

Coverage is 83.791%NEW-HEAT:codex/terrain-globe-mercator-remap into visgl:cr/feat/terrain-layer-globe-grid. No base build found for visgl:cr/feat/terrain-layer-globe-grid.

meshMaxError,
signal
})?.then(mesh =>
viewport.resolution && mesh ? remapMeshToWebMercatorTile(mesh, overlappedBounds) : mesh
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure how much this costs - seems heavy.

Easier to handle directly in loadTerrain? Gotta check

};
}

function lngLatToMercatorY(latitude: number): number {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math.gl?

const isTileSetURL = (url: string): boolean =>
url.includes('{x}') && (url.includes('{y}') || url.includes('{-y}'));

function remapMeshToWebMercatorTile(mesh: Mesh, bounds: Bounds): Mesh {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math.gl?

@charlieforward9 charlieforward9 marked this pull request as ready for review May 13, 2026 04:19
@charlieforward9 charlieforward9 linked an issue May 13, 2026 that may be closed by this pull request
7 tasks
@felixpalmer felixpalmer deleted the branch visgl:cr/feat/terrain-layer-globe-grid May 15, 2026 14:16
@charlieforward9 charlieforward9 self-assigned this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Projection issue with TileLayer on low-zoom GlobeView

3 participants